package com.st.sprinbootevent.listener;

import com.st.sprinbootevent.event.CustomEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author zhangli
 */
@Component
public class CustomListener implements ApplicationListener<CustomEvent> {
    @Override
    public void onApplicationEvent(CustomEvent event) {
        System.out.println("---------------------");
        String source = (String) event.getSource();
        System.out.println("CustomListener: " + source);
        String msg = event.getMsg();
        System.out.println(msg);
        System.out.println("---------------------");
    }

    @Override
    public boolean supportsAsyncExecution() {
        return ApplicationListener.super.supportsAsyncExecution();
    }
}
